package com.keqiang.chart.impl.pie.impl.normal

import android.graphics.Canvas
import com.keqiang.chart.base.BaseChartView
import com.keqiang.chart.impl.pie.BasePieChart
import com.keqiang.chart.impl.pie.BaseTouchHandler
import com.keqiang.chart.impl.pie.render.BaseDataRender
import com.keqiang.chart.impl.pie.render.BaseLabelRender

/**
 * 饼状图
 *
 * @author Created by wanggaowan on 2022/8/2 15:14
 */
open class PieChart(view: BaseChartView<*>) : BasePieChart<List<PieEntity>>(view) {

    override var touchHandler: BaseTouchHandler<PieChart, PieEntity>? = PieChartTouchHandler(this)

    override var labelRender: BaseLabelRender<PieChart>? = PieChartLabelRender(this)

    var highLightRender: HighLightRender? = PieChartHighLightRender(this)

    override fun isEmptyData(): Boolean {
        return data.isNullOrEmpty()
    }

    override val dataRender: BaseDataRender<PieChart> = PieChartDataRender(this)
}

/**
 * 高亮数据绘制器
 *
 * @author Created by wanggaowan on 2022/8/8 15:03
 */
abstract class HighLightRender(val chart: PieChart) {
    /**
     * 绘制高亮数据
     */
    abstract fun onDraw(canvas: Canvas, drawStartAngle: Float, drawSweepAngle: Float, data: PieEntity)

    /**
     * 返回高亮绘制内容的半径
     */
    abstract fun getRadius(data: PieEntity): Float

    /**
     * 获取X轴，Y轴偏移值
     * @return 第一个参数为X轴偏移距离，第二个参数为Y轴偏移距离
     */
    abstract fun getOffset(data: PieEntity): Pair<Float, Float>
}


